/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rowan.infovis.soccer;

import com.sun.opengl.util.GLUT;
import com.sun.opengl.util.j2d.TextRenderer;
import java.awt.Color;
import java.awt.Font;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;

public class Movement {

    private int value;
    private GLAutoDrawable drawable;
    private FieldViewer fv;

    public Movement(int value, GLAutoDrawable drawable, FieldViewer fv) {
        this.value = value;
        this.drawable = drawable;
        this.fv = fv;
    }

    public void draw(GL gl) {
        GLUT glut = new GLUT();

        gl.glColor3f(1f, 1f, 1f);

        gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(0.0, 0.0);
        gl.glVertex2d(150.0, 0.0);
        gl.glEnd();

        double translate = 0;

        gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(0.0, -15.0);
        gl.glVertex2d(0.0, 15.0);
        gl.glEnd();

        gl.glPushMatrix();
        gl.glTranslated(50.0, 0.0, 0.0);
        gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(0.0, -15.0);
        gl.glVertex2d(0.0, 15.0);
        gl.glEnd();
        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glTranslated(100.0, 0.0, 0.0);
        gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(0.0, -15.0);
        gl.glVertex2d(0.0, 15.0);
        gl.glEnd();
        gl.glPopMatrix();

        gl.glPushMatrix();
        gl.glTranslated(150.0, 0.0, 0.0);
        gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(0.0, -15.0);
        gl.glVertex2d(0.0, 15.0);
        gl.glEnd();
        gl.glPopMatrix();

        String label = null;

        TextRenderer tr = new TextRenderer(new Font("SansSerif", Font.BOLD, 16));
        tr.beginRendering(drawable.getWidth(), drawable.getHeight());
        tr.draw("Slow Execution of Movement", (int) fv.FIELD_X + 65, (int) ((int) fv.FIELD_Y + (fv.FIELD_HEIGHT / 4)) - 10);
        tr.endRendering();

        if (value == 1) {
            translate = 0;
            gl.glColor3f(1f, 0f, 0f);
            label = "Very Often";
            tr.setColor(Color.RED);
        } else if (value == 2) {
            gl.glColor3f(1f, 0.563f, 0f);
            translate = 50;
            label = "Often";
            tr.setColor(1f, 0.563f, 0f, 1f);
        } else if (value == 3) {
            gl.glColor3f(1f, 1f, 0f);
            translate = 100;
            label = "Rare";
            tr.setColor(Color.YELLOW);
        } else if (value == 4) {
            gl.glColor3f(0f, 1f, 0f);
            translate = 150;
            label = "Very Rare";
            tr.setColor(Color.GREEN);
        }

        tr.beginRendering(drawable.getWidth(), drawable.getHeight());
        tr.draw(label, (int) fv.FIELD_X + 65, (int) ((int) fv.FIELD_Y + (fv.FIELD_HEIGHT / 4)) - 35);
        tr.endRendering();

        gl.glPushMatrix();
        int dot_radius = 8;
        GLU glu = new GLU();
        GLUquadric dot = glu.gluNewQuadric();
        gl.glTranslated(translate, 0, 0);
        glu.gluQuadricDrawStyle(dot, GLU.GLU_FILL);
        glu.gluDisk(dot, 0, dot_radius, 60, 60);
        gl.glPopMatrix();
    }
}
